import React,{Component} from 'react'
import * as pub from '../../config/public';
import {Spin} from 'antd'
import * as fetch from '../../config/fetch';
class User extends Component {
	constructor(props) {
		super(props);
		this.state={
			userData:{},
			loading:false,
			score:0
		}
	}
    componentWillMount() {
		pub.loading(this,true);
		fetch.getMoreone().then((data)=>{
			this.setState({
				userData:data.user?data.user:{},
				score:data.score
			})
			pub.loading(this,false);
		}, (res) => {
			pub.loading(this,false);
			pub.reject(res);
		})
	}
	render(){
		let userData=this.state.userData;
		return(
				   <div className="panel-27 bg-FFFFFF box-shadow">
						<div className="user-info-box">
							<Spin spinning={this.state.loading} tip="加载列表中...">
							{
								userData.headPath !==''?
									<img src={pub.getFile(userData.headPath)} alt='封面图片' onError={(e) => pub.headImageError(e)}/>
								:
									<img src={require('../../style/images/portrait.png')} alt='head' />
							}
							
							<p>{userData.userRealName}</p>
							<ul className="info-details">
								<li>性别<span>{userData.sex===0?userData.sex='女':userData.sex='男'}</span></li>
								<li>公司<span>{userData.branceOffice}</span></li>
								<li>职务<span>{userData.jobName}</span></li>
								<li>生日<span>{userData.birthday}</span></li>
								<li>学历<span>{userData.education}</span></li>
								<li>会员等级<span>{userData.vipGradName}</span></li>
								<li>可用积分<span>{this.state.score}</span></li>
							</ul>
							</Spin>
						</div>
					</div>
			)
	}
}
export default User;